package com.google.gson.internal.bind;

import com.google.gson.a.a;
import com.google.gson.b.d;
import java.io.IOException;
import java.lang.reflect.Type;

final class x extends TypeAdapter {
    private final l a;
    private final TypeAdapter b;
    private final Type c;

    x(l lVar, TypeAdapter typeAdapter, Type type) {
        this.a = lVar;
        this.b = typeAdapter;
        this.c = type;
    }

    public void a(d dVar, Object obj) throws IOException {
        TypeAdapter typeAdapter = this.b;
        Type a = p.a(this.c, obj);
        if (a != this.c) {
            typeAdapter = this.a.a(a.a(a));
            if ((typeAdapter instanceof r) && !(this.b instanceof r)) {
                typeAdapter = this.b;
            }
        }
        typeAdapter.a(dVar, obj);
    }

    public Object b(com.google.gson.b.a aVar) throws IOException {
        return this.b.b(aVar);
    }
}
